#include "../../common/detail.hpp"
#include "../../client/client.hpp"
#include "../../client/rpc_topic.hpp"
#include <chrono>
#include <iostream>
#include <thread>

void topicCallBack(const std::string& key, const std::string& msg)
{
    ILOG("%s,客户端收到消息： %s",key.c_str(),msg.c_str());
}
int main()
{
    // 发布客户端
    qiangsir::client::TopicClient::ptr client = std::make_shared<qiangsir::client::TopicClient>("127.0.0.1", 8080);
    // 创建主题
    bool ret = client->create("音乐");
    if (ret == false)
    {
        ELOG("主题创建失败");
    }
    //订阅主题
    DLOG("主题创建成功");
    client->subsribe("音乐",topicCallBack);
    DLOG("主题发布成功");
    //4. 等待->退出
    std::this_thread::sleep_for(std::chrono::seconds(10));
    client->onShutdown();
    return 0;
}